# 导包
from common.base import *


class After(Base):
    # 定位管理员用户名
    def get_admin_name(self):
        return self.get_text((By.XPATH, '//*[@id="foot-div"]/a'))

    # ((By.XPATH, '//*[@id="listDiv"]/table[1]/tbody/tr[3]/td[3]/span'))
    def commodity(self):
        self.click((By.XPATH, '//*[@id="menu-ul"]/li[2]'))  # 定位商品管理按钮并点击

    def add_new_item(self):
        self.click((By.LINK_TEXT, '添加新商品'))  # 定位添加新商品并点击

    def trade_name(self, text):
        self.click((By.XPATH, '//input[@name="goods_name"]'))  # 定位商品名称框并点击
        # time.sleep(2)
        self.send_keys((By.XPATH, '//input[@name="goods_name"]'), text)  # 输入商品名称

    def classification(self, value):
        self.click((By.XPATH, '//*[@id="general-table"]/tbody/tr[3]/td[2]/select'))  # 定位商品分类并点击‘
        self.select((By.XPATH, '//*[@id="general-table"]/tbody/tr[3]/td[2]/select'), value)
        # 定位下拉框通过设置value来选择参数

    def our_selling_price(self, text):
        self.click((By.XPATH, '//*[@id="general-table"]/tbody/tr[7]/td[2]/input[1]'))  # 定位本店售价并点击
        self.clear_text((By.XPATH, '//*[@id="general-table"]/tbody/tr[7]/td[2]/input[1]'))  # 清除本店售价输入框里面的值0
        self.send_keys((By.XPATH, '//*[@id="general-table"]/tbody/tr[7]/td[2]/input[1]'), text)  # 输入商品数量

    def determine(self):
        self.click((By.XPATH, '//*[@id="tabbody-div"]/form/div/input[2]'))  # 定位确定按钮并点击

    # 获取新增的商品名称
    def get_new_shop_name(self):
        return self.get_text((By.XPATH, '//*[@id="listDiv"]/table[1]/tbody/tr[3]/td[3]/span'))

    # 订单管理
    def order_commodity(self):
        self.click((By.XPATH, '//*[@id="menu-ul"]/li[4]'))

    # 订单列表第一个订单号
    def order_list_number(self):
        return self.get_text((By.XPATH, '//*[@id="order_0"]'))




